package com.dxt.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * 使用direct模式测试消息生产者的消息确认和返回机制
 */
@Component
public class ConfirmAndReturnConfig {
    public static final String EXCHANGE = "confirm_return_exchange";
    public static final String QUEUE = "confirm_return_queue";
    public static final String ROUTING_KEY = "confirm_and_return";

    @Bean
    public Queue getQueue(){
        return new Queue(ConfirmAndReturnConfig.QUEUE);
    }
    @Bean
    public Exchange getExchange(){
        return new DirectExchange(ConfirmAndReturnConfig.EXCHANGE);
    }
    @Bean
    public Binding binding(){
        return BindingBuilder.bind(getQueue()).to(getExchange()).with(ConfirmAndReturnConfig.ROUTING_KEY).noargs();
    }
}
